function oobErr = oobErrRF(params,X,y, NumTrees, str_method)

%   oobErrRF Trains random forest and estimates out-of-bag quantile error
%   oobErr trains a random forest of NumTrees str_method 
%   (regression/classification) trees using the
%   predictor data in X and the parameter specification in params, and then
%   returns the out-of-bag quantile error based on the median. X is a table
%   and params is an array of OptimizableVariable objects corresponding to
%   the minimum leaf size and number of predictors to sample at each node.

randomForest = TreeBagger(NumTrees,X,y,'Method',str_method,...
    'OOBPrediction','on','MinLeafSize',params.minLS,...
    'NumPredictorstoSample',params.numPTS);
oobErr = oobQuantileError(randomForest);

end